package com.tmsps.ne4Weixin.api.entity.menu;

import java.util.ArrayList;
import java.util.List;

import com.tmsps.ne4Weixin.api.entity.BaseModel;

public class MenuButton extends BaseModel {
	public enum MenuType {
		CLICK("click"), view("view"), SCANCODE_PUSH("scancode_push"), PIC_SYSPHOTO("pic_sysphoto"), PIC_PHOTO_OR_ALBUM("pic_photo_or_album"), PIC_WEIXIN("pic_weixin"), LOCATION_SELECT("location_select"), MEDIA_ID("media_id"), VIEW_LIMITED("view_limited");

		private String type;

		private MenuType(String type) {
			this.type = type;
		}

		public String toString() {
			return this.type;
		}

	}

	// 菜单类型
	private String type;
	// 菜单名称
	private String name;
	// 菜单key click等点击类型必须 菜单KEY值，用于消息接口推送，不超过128字节
	private String key;
	// 跳转地址
	private String url;
	// 媒体ID
	private String media_id;
	// 子菜单
	private List<MenuButton> sub_button = new ArrayList<MenuButton>();

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getMedia_id() {
		return media_id;
	}

	public void setMedia_id(String media_id) {
		this.media_id = media_id;
	}

	public List<MenuButton> getSub_button() {
		return sub_button;
	}

	public void setSub_button(List<MenuButton> sub_button) {
		if (null == sub_button || sub_button.size() > 5) {
			throw new IllegalArgumentException("子菜单最多只有5个");
		}
		this.sub_button = sub_button;
	}

	public void addMenuButton(MenuButton mb) {
		this.sub_button.add(mb);
		if (sub_button.size() > 5) {
			throw new IllegalArgumentException("子菜单最多只有5个");
		}
	}

}
